package dse.messages;

public enum MessagePurpose {
	DataObjectRequest,
	BloomFilterRefresh,
	Caching,
	DataObjectUpdate,
	SVR,
	ResumeFromFailure;
	
	public static int toInt (MessagePurpose purpose) {
		if (purpose == DataObjectRequest)
			return 0;
		else if (purpose == BloomFilterRefresh)
			return 3;
		else if (purpose == Caching)
			return 4;
		else if(purpose == DataObjectUpdate)
			return 1;
		else if(purpose == SVR)
			return 2;
		return -1;
	}

	public static MessagePurpose fromInt (int i) 
	throws IndexOutOfBoundsException {
		if (i < 0 || i >= MessagePurpose.values().length) 
			throw new IndexOutOfBoundsException("Invalid ordinal");
		return MessagePurpose .values()[i];
	}
}
